package org.xfy.org.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.xfy.base.service.impl.BaseServiceImpl;
import org.xfy.base.util.AjaxResult;
import org.xfy.org.domain.Employee;
import org.xfy.org.domain.vo.EchartsVo;
import org.xfy.org.mapper.EmployeeMapper;
import org.xfy.org.service.IEmployeeService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class EmployeeServiceImpl extends BaseServiceImpl<Employee> implements IEmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public AjaxResult echarts() {
        List<EchartsVo> list = employeeMapper.echarts();
        Map<String, Object> map = new HashMap<>();
        List<Integer> CountNum = list.stream().map(EchartsVo::getCountNum).collect(Collectors.toList());
        List<String> time = list.stream().map(EchartsVo::getTime).collect(Collectors.toList());
        map.put("y",CountNum);
        map.put("x",time);
        return AjaxResult.me().setResultObj(map);
    }
}
